import Vue from "vue";
import VueRouter from "vue-router";
import consult from "@/views/consult";
import Home from "@/views/Home";
import House from "@/views/House";
import My from "@/views/My";
import Layout from "@/views/Layout";
import Login from "@/views/Login";
import CltyList from "@/views/cltyList";
import Collection from "@/views/Collection";
import Map from "@/views/Map";
import Rend from "@/views/Rend";
import HouseSearch from "@/views/HouseSearch";
import rentGuanage from "@/views/rentGuanage";
import detail from "@/views/detail";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: "/layout",
  },
  {
    path: "/layout",
    redirect: "/layout/home",
    component: Layout,
    children: [
      {
        path: "consult",
        component: consult,
      },
      {
        path: "home",
        component: Home,
        props($route) {
          return {
            name: $route.query.name,
          };
        },
      },
      {
        path: "house",
        component: House,
      },
      {
        path: "my",
        component: My,
      },
    ],
  },
  {
    path: "/login",
    component: Login,
  },
  {
    path: "/cityList",
    component: CltyList,
    props($route) {
      console.log($route);
      return {
        level: $route.query.level,
        city: $route.query.city,
      };
    },
  },
  {
    path: "/collection",
    component: Collection,
  },
  {
    path: "/map",
    component: Map,
  },
  {
    path: "/rend",
    component: Rend,
  },
  {
    path: "/houseSearch",
    component: HouseSearch,
  },
  {
    path: "/rentGuanage",
    component: rentGuanage,
  },
  {
    path: "/detail/:id",
    component: detail,
    name: "xiangqing",
    props($route) {
      return { id: $route.params.id };
    },
  },
];

export default new VueRouter({ routes });
